package org.ndx.majick.ui.object;

import java.awt.GridLayout;
import java.util.Collection;
import java.util.Map;

import javax.swing.JComponent;
import javax.swing.JPanel;

import org.ndx.majick.properties.Property;
import org.ndx.majick.ui.IPanelProvider;

public class ObjectPanelProvider implements IPanelProvider {

	public JPanel getPanel(String mode, Object object,
			Collection<Property<?>> properties,
			Map<Property<?>, JComponent> propertiesToLabels,
			Map<Property<?>, JComponent> propertiesToRenderers) {
		JPanel returned = new JPanel();
		returned.setName("UIGenerator."+object.getClass().getName()+"."+mode);
		returned.setLayout(new GridLayout(properties.size(), 2));
		for (Property<?> property : properties) {
			returned.add(propertiesToLabels.get(property));
			returned.add(propertiesToRenderers.get(property));
		}
		return returned;
	}

}
